1. Field of the Invention
The present application relates generally to an improved data processing system and in particular, to a computer implemented method, apparatus, system, and computer usable program code for scheduling processes. Still more particularly, the present invention relates to a computer implemented method, apparatus, and computer usable program code for controlling the priority preemption of process execution in a data processing system.
2. Description of the Related Art
Multitasking is a method by which multiple processes can share common processing resources, such as a central processing unit (CPU). A single central processing unit or processor can only execute a single process at any given point in time. As used herein, a process is a running instance of a program, a task, thread, or other item of work to be performed by a processor. The term “running” refers to a processor actively executing the instructions of a process.
During multitasking, a scheduler schedules which process will be the one process running at a given time and when another process waiting for execution will be run by the processor. Typically, a processor is scheduled to switch execution between the processes waiting for execution to give the appearance that many processes are executing simultaneously on the same processor.
For example, if a processor has two processes to execute, the scheduler will assign the processor to run the first process for a given time period, then assign the processor to switch to executing the second process for a given time period, and then switch back to executing the first process to give the appearance that both processes are being executed at the same time. The act of reassigning a processor from executing one process to another process is called a context switch. When context switches occur frequently enough, the illusion of simultaneous processing is achieved.
The scheduler typically schedules processes for execution according to the priority of the process. In other words, a process that has a higher priority is scheduled for execution by the processor before a process with a lower priority. The priority of a process is determined by the scheduler based on user defined priorities for processes, the type of process, and/or process behavior. For example, a process that requires greater execution time may be given a lower priority than a process that requires less time for execution.
In some cases, a higher priority process becomes ready for execution after another process has already been assigned to the processor for execution. In such a case, the scheduler can use priority preemption. Priority preemption provides a scheduler with the ability to assign a process that is ready to run in place of another lower priority process that is already running. Priority preemption refers to preempting an existing process because a new process with a higher priority is ready to run. Preempting an existing process refers to stopping execution of the currently running process.
In other words, if a new process becomes ready for execution and the new process has a greater priority than a process that is already being executed by the processor, the scheduler can preempt or stop execution of the current process to permit execution of the new higher priority process to begin.
A scheduler will preempt a current process when a preemption point is detected. A preemption point is the point when a new process becomes run ready and the new process is determined to have a higher priority than the current running process. The scheduler performs a context switch from the current process to the new process each time a preemption point is detected.
The scheduler performs a context switch by suspending execution of the current process, initiating execution of the new higher priority process, and flushing the translation look-aside buffer (TLB) if the new higher priority process does not share the same virtual memory address space as the preempted process.
The process of priority preemption provides the appearance of simultaneous multitasking through low scheduling latency. However, high rates of priority preemption can cause reduction in cache warmth, increases in translation look-aside buffer misses where the new process does not share the same virtual memory address space, and wastes processor cycles on excessive context switches.